home *** CD-ROM | disk | FTP | other *** search
- From: brianmcg@interaccess.com (Brian V. McGroarty)
- Message-ID: <4jgpqa$t09@nntp.interaccess.com>
- X-Original-Date: 29 Mar 1996 13:50:02 GMT
- Path: in2.uu.net!bounce-back
- Date: 30 Mar 96 05:46:49 GMT
- Approved: fjh@cs.mu.oz.au
- Return-Path: <daemon@meeker.UCAR.EDU>
- Newsgroups: comp.std.c++
- Subject: Const class member
- Organization: Internet Squire
- Reply-To: brianmcg@interaccess.com
- X-Newsreader: Internet Squire 1.20
- X-Auth: PGPMoose V1.1 PGP comp.std.c++
- iQBFAgUBMVzK1OEDnX0m9pzZAQGYgwF/dbBcO6j67CzzpYGFvO3mKbaRFB+D0wg1
- BlqNx35Ycjs3vClZ3siiQlHsC97HHNHe
- =pace
-
- Is this legal? Borland and Microsoft compilers will accept the following:
-
- class AnyClass
- {
- const int constInt;
- }
-
- The Borland compiler complains about the uninitialized constant, whereas
- the Microsoft compiler does not. If a constructor is present, both will
- complain that the constant isn't initialized in the constructor, however
- neither will allow you to assign a value in the constructor by simply
- specifying "constInt= some value". I have also attempted to initialize in
- a global variable "int AnyClass::constInt", to determine whether static
- somehow became implicit -- still no go. If this is legal, how is the value
- initialized?
-
- Would compilers stand a better chance of optimizing given the above via
- constant propogation through inlined (member only?) functions applied to a
- hard-coded instance of the object, or would it just be to help prevent
- programmers' error?
-
- ---
- Brian Valters McGroarty -- brianmcg@bix.com
- phone/fax (847) 439-7714
- ---
- [ comp.std.c++ is moderated. To submit articles: try just posting with ]
- [ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
- [ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
- [ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
- [ Comments? mailto:std-c++-request@ncar.ucar.edu ]
-